Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update short guide of dev setup #3285

Closed
wants to merge 20 commits into from
Closed

docs: update short guide of dev setup #3285

wants to merge 20 commits into from

Conversation

brunoffranca
Copy link
Member

@brunoffranca brunoffranca commented Nov 14, 2024

What ❔

Updates the setup dev guide and turns it into a fully automated script. You just need to run one curl command and everything will be installed with no user input. Also fixed some minor issues with the previous guide:

  • Removed the HTTPS configuration for git. Instead uses HTTPS by default since that's Github recommendation.
  • Installs git along with the other necessary packages.
  • Adds --locked flag to cargo-nextest installation since that's the recommended way.
  • Changed installation steps order to make more sense (ex: we were installing curl after using it).
  • Included ZK Stack CLI in the installation instead of having it separate.

@brunoffranca brunoffranca marked this pull request as draft November 15, 2024 02:10
@brunoffranca
Copy link
Member Author

brunoffranca commented Nov 15, 2024

On the Foundry-zksync install script, we probably need to add . "$SHELL_CONFIG_FILE" after echo "Installation completed successfully!" since the verification afterwards fails (running source ~/.bashrc solved it on my machine).

Update: Replacing if forge --version | grep -q "0.0.2" with if "$HOME/.foundry/bin/forge" --version | grep -q "0.0.2" should do the trick.

Update: I'm waiting for write permissions to add this fix. It doesn't impact this PR though.

Update: matter-labs/foundry-zksync#733

@brunoffranca brunoffranca marked this pull request as ready for review November 15, 2024 17:18
@brunoffranca
Copy link
Member Author

Weird. When running zkstack dev fmt or zkstack dev lint after this installation, it complains that Prettier is not installed. But I can check that it is.

docs/src/guides/setup-dev.md Outdated Show resolved Hide resolved
docs/src/guides/setup-dev.md Outdated Show resolved Hide resolved

# Start Docker
say "Starting Docker..."
sudo systemctl start docker
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to usermod as well?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIU the usermod change is just to be able to run docker commands without sudo. In fact, in my test machine, docker is running after this command.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably user on your test machine has root access, and ability to run docker commands without sudo is super important, so it must be a part of initialization.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it important?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because it's a major security prerequisite. Giving docker root access is a bad idea (and in general, you should never give sudo access to anything unless there is a strong request for it). And, well, it's just not convenient to have always run commands with sudo. Plus it will break e.g. zkstack CLI because it will (correctly) run docker commands without sudo.

Copy link
Member Author

@brunoffranca brunoffranca Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding security, I'd argue exactly the reverse. With sudo you have to input a password for any docker command, thus requiring human approval. If you add the user to the docker group you effectively allow any app with non-root privileges access to the docker commands.
https://www.reddit.com/r/docker/comments/syngw7/to_sudo_or_not_to_sudo_that_is_the_question/

But yeah, if zkstack breaks, then usermod is needed.

docs/src/guides/setup-dev.sh Show resolved Hide resolved
docs/src/guides/setup-dev.sh Outdated Show resolved Hide resolved
@brunoffranca
Copy link
Member Author

@Deniallugo Am I supposed to install prettier for zksync-era after installing ZK Stack CLI?

@brunoffranca brunoffranca requested a review from popzxc November 20, 2024 13:26
@Deniallugo
Copy link
Contributor

@brunoffranca no you shouldn't, it just must exist in your system

initializing the workspace, it's recommended that you read the whole guide below, as it provides more context and tips.

If you run on 'clean' Ubuntu on GCP:
Just run the following command on Debian-based Linux:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also hesitatnt to suggest blindly running it. If the script will be run on a machine where, e.g., docker is already installed (especially if it was installed in some other way), it can mess up the configuration.

Do we really need to have a script here? If so, I'd probably want to make it fail-proof, e.g. that it won't do stuff that is not needed, but it's a much bigger effort.

The benefit of a code block is that you see the code and can choose what lines you need and what lines you don't need.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are to keep this, I'd add some big red warning that you should first read the script code and make sure that it does what you need (which though would render it much less helpful).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, but the original setup guide specifically says that the code is to be run on a fresh GCP instance. So it seems reasonable that we have a fast setup option for those cases at least.
I can add a code block below with what's in the script, so that people can inspect it though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original -- yes, the new one removed mention of GCP.
Regarding code block -- it would mean duplication, and script will likely get out of sync with the code block.

Copy link
Member Author

@brunoffranca brunoffranca Nov 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really think it's possible to create a fail-proof version of this script (at least without a disproportionate amount of work). And if we don't want duplication then the only possible solution is for me to close this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really think it's possible to create a fail-proof version of this script (at least without a disproportionate amount of work).

Yup, I agree, and that's exactly the reason why it wasn't done before.

And if we don't want duplication then the only possible solution is for me to close this PR.

Was there any reason why we need a script except for making usage simpler?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, just to make usage simpler. I created one for myself, since I have to run fresh dev nodes with some frequency, and thought it would be useful for more people.

Comment on lines -11 to -13
# For VMs only! They don't have SSH keys, so we override SSH with HTTPS
git config --global url."https://github.com/".insteadOf [email protected]:
git config --global url."https://".insteadOf git://
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines are important for VMs, because submodule fetching may break if running on a fresh machine without valid ssh keys; however they're missing in the script.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The standard now really is to declare submodules with https, like we do. I did follow the tree of submodules down and it seems all of them use https.
Do you think it's worth it to keep this, since it's such a small edge case?

@brunoffranca brunoffranca deleted the bf-dev-setup branch November 27, 2024 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants